<!DOCTYPE html>
<html>
<#include "../head.html">
<body class="full">
<div class="mc">
    <div class="mc-l">
        <!--左侧导航---{-->
        <div id="navPanelContainer">
            <div class="system-logo cd"></div>
            <!--管理员信息---{-->
            <#include "../adminInfo.html">
                <!--管理员信息---}-->
                <div class="nav-wrap">
                    <#include "left.html">
                </div>
        </div>
        <!--左侧导航---}-->
    </div>
    <div class="mc-m">
        <div class="navToggle"></div>
    </div>
    <div class="mc-r">
        <!--顶部导航---{-->
        <#include "../topNav.html">
            <!--顶部导航---}-->

            <!--面包屑导航---{-->
            <#assign moduleName="邀请管理">
                <#include "banner.html">
                    <!--面包屑导航---}-->

                    <!--工具栏--{-->
                    <div id="toolbar" class="clearfix">

                        <div class="toolbor-module search">
                            <input type="button" value="搜索"  class="input-button" onclick="sousuo();">
                        </div>

                        <div class="toolbor-module search">
                            <div class="formTit">状态：</div>
                            <div class="select-box" id="sendFlag">
                                <div class="tag-select">全部</div>
                                <ul class="tag-options">
                                    <li data-value="">全  部</li>
                                    <li data-value="1">已派送</li>
                                    <li data-value="0">未派送</li>
                                </ul>
                            </div>
                        </div>

                        <div class="toolbor-module search">
                            <div class="formTit">邀请人：</div>
                            <input type="text" name="userName" id="userName" value="请输入用户名"  class="search-value">
                        </div>

                        <div class="toolbor-module search">
                            <div class="formTit">邀请日期：</div>
                            <input class="_search-value" name="startDate" id="startDate" value="" onclick="change_picktime()"/>
                            <div class="formTit"> 到 </div>
                            <input class="_search-value" name="endDate" id="endDate" value="" id="" onclick="change_picktime()"/>
                        </div>
                        <div class="toolbor-module export">
                            <input type="button" value="一键派发"  class="input-button" id="allpai" autocomplete=off>
                        </div>

                    </div>
                    <!--工具栏--}-->

                    <div id="main" class="clearfix">
                        <form action="" method="post">
                            <table class="data-list" id="dataList">
                                <tr class="header">
                                    <td>序号(ID)</td>
                                    <td>邀请人</td>
                                    <td>邀请人真实姓名</td>
                                    <td>被邀请人</td>
                                    <td>被邀请人真实姓名</td>
                                    <td>被邀请人实名状态</td>
                                    <td>累计投资金额</td>
                                    <td>邀请日期</td>
                                    <td>状态</td>
                                </tr>
                                <#import "../../common/function.html" as func>
                                    <#list list as item>
                                        <tr class="s">
                                            <td>${item.id?c}</td>
                                            <td><a href="/admin/friend/viewUserTenderRecord.html?userId=${item.userId?c}">${item.userName!''}</a></td>
                                            <td>${item.realName!''}</td>
                                            <td><a href="/admin/friend/viewUserTenderRecord.html?userId=${item.inviteUserId?c}">${item.inviteUserName!''}</a></td>
                                            <td>${item.inviteRealName!''}</td>
                                            <td><#if item.realStatus == 1><font color="green">是</font><#else><font color="red">否</font></#if></td>
                                            <td>${item.tenderTotal?c}元</td>
                                            <td>${item.createDate!''}</td>
                                            <td>
                                                <!-- edited by chenyuan 20150906 -->
                                                <!-- <#if item.sendFlag == 2>
                                                    <span style="color:green">已派送</span>
                                                <#elseif item.tenderTotal gte 5000 && item.sendFlag != 2>
                                                    <a class="js_send"  href="/admin/friend/sendRedPacket.html?id=${item.id?c}&userId=${item.userId?c}&inUserId=${item.inviteUserId?c}" style="color:#0099ff">未派送</a>
                                                <#else>
                                                    -
                                                </#if> -->
                                                <!-- <#if item.sendFlag == 2>
                                                    <span style="color:green">已派送</span>
                                                <#elseif item.tenderTotal gte 100 && item.tenderTotal lt 500>
                                                    <#if item.sendFlag != 1>
                                                        <a class="js_send"  href="/admin/friend/sendRedPacket.html?id=${item.id?c}&userId=${item.userId?c}&inUserId=${item.inviteUserId?c}" style="color:#0099ff">未派送</a>
                                                    <#else>
                                                        <span style="color:green">已派送</span>
                                                    </#if>
                                                <#elseif item.tenderTotal gte 500 && item.tenderTotal lt 5000>
                                                    <#if item.sendFlag != 3>
                                                        <a class="js_send"  href="/admin/friend/sendRedPacket.html?id=${item.id?c}&userId=${item.userId?c}&inUserId=${item.inviteUserId?c}" style="color:#0099ff">未派送</a>
                                                    <#else>
                                                        <span style="color:green">已派送</span>
                                                    </#if>
                                                <#elseif item.tenderTotal gte 5000>
                                                    <#if item.sendFlag != 2>
                                                        <a class="js_send"  href="/admin/friend/sendRedPacket.html?id=${item.id?c}&userId=${item.userId?c}&inUserId=${item.inviteUserId?c}" style="color:#0099ff">未派送</a>
                                                    <#else>
                                                        <span style="color:green">已派送</span>
                                                    </#if>
                                                <#else>
                                                    -
                                                </#if> -->
                                                <#if item.sendFlag == 2>
                                                    <span style="color:green">已派送</span>
                                                    <#elseif item.tenderTotal gte 500 && item.tenderTotal lt 5000>
                                                        <#if item.sendFlag != 1 && item.sendFlag != 3>
                                                            <a class="js_send"  href="/admin/friend/sendRedPacket.html?id=${item.id?c}&userId=${item.userId?c}&inUserId=${item.inviteUserId?c}" style="color:#0099ff">未派送</a>
                                                            <#else>
                                                                <span style="color:green">已派送</span>
                                                        </#if>
                                                        <#elseif item.tenderTotal gte 5000>
                                                            <#if item.sendFlag != 2>
                                                                <a class="js_send"  href="/admin/friend/sendRedPacket.html?id=${item.id?c}&userId=${item.userId?c}&inUserId=${item.inviteUserId?c}" style="color:#0099ff">未派送</a>
                                                                <#else>
                                                                    <span style="color:green">已派送</span>
                                                            </#if>
                                                            <#else>
                                                                -
                                                </#if>
                                            </td>
                                        </tr>
                                    </#list>
                            </table>
                        </form>

                        <!--底部工具栏--{-->
                        <div id="bottomToolbar" class="clearfix">
                            <div class="other-tool">
                                <dl class="refresh-data">
                                    <dt class="refresh-data-icon"></dt>
                                    <dd><a href="javascript:void(0);"  class="refresh-page">刷新数据</a></dd>
                                </dl>
                            </div>

                            <!--翻页系统--{-->
                            <div class="container s_formPage">
                                <#import "../../common/page.html" as pager>
                                    <@pager.pagination page=page url="${pageUrl}" map=param style="style1" />
                            </div>
                            <!--翻页系统--}-->
                        </div>
                        <!--底部工具栏--}-->

                        <script>
                            var urls = '?search=true';
                            function sousuo(){
                                var sou = "";
                                var userName = $("#userName").val();
                                if (userName!=null&&userName!=""&&userName!="undefine"&&userName!="请输入用户名"){
                                    sou += "&userName="+userName;
                                }
                                var sendFlag = $("#sendFlag").find(".open-selected").attr("data-value");
                                if(sendFlag!=null&&sendFlag!=""&&sendFlag!="undefine"){
                                    sou += "&sendFlag="+sendFlag;
                                }
                                var startDate = $("#startDate").val();
                                var endDate = $("#endDate").val();
                                if (startDate!=null){
                                    sou += "&startDate="+startDate;
                                }
                                if (endDate!=null){
                                    sou += "&endDate="+endDate;
                                }
                                var url=urls+sou
                                location.href=url;
                            }

                            /*
                                $("#dataList tr:gt(0)").each(function(){
                                    var oThis=$(this),
                                        iMoney=parseInt(oThis.children('td').eq(6).text()),
                                        oStatus=oThis.children('td').last();
                                    if(oStatus.attr('data-status')==2){
                                        oStatus.html('<span style="color:green">已派送</span>');
                                    }else if(iMoney>=5000 && oStatus.attr('data-status') !=2){
                                        oStatus.html('<a id="send"  href="/admin/friend/sendRedPacket.html?id='+oStatus.attr('data-id')+'&userId='+oStatus.attr('data-uid')+'&inUserId='+oStatus.attr('data-inuid')+'" style="color:#0099ff">未派送</a>');
                                    }else{

                                    }
                                }); */

                            $(".js_send").click(function(){
                                if(confirm("是否确认派送红包？")){
                                    return true;
                                }else{
                                    return false;
                                }
                            });

                            /*



                        */
                            $("#allpai").click(function(){
                                time();
                                var a=0;
                                $this=$(".js_send");
                                for(var i=0;i<$this.length;i++){
                                    webAction($this[i].href);
                                    a++;
                                }
                                setTimeout(function(){
                                    alert("本次派发"+a+"条");
                                    location.reload();
                                },3000) //单位毫秒
                            });

                            function webAction(url){
                                $.ajax({
                                    type: 'get',
                                    url: url,
                                    dataType: "json"
                                });
                            }
                            //秒倒计时
                            var tmpWait = 10;
                            function time() {
                                if (tmpWait>0) {
                                    $('.export input').attr("disabled", true);
                                    $('.export input').val(tmpWait + "s后再试");
                                    --tmpWait;
                                    setTimeout(function() {
                                            time();
                                        },
                                        1000)
                                } else {
                                    tmpWait = 10;
                                    $('.export input').removeAttr("disabled");
                                    $('.export input').val("一键派发");
                                }
                            }
                        </script>
                    </div>
    </div>
</div>
<div class="mc-b">
    <#include "../foot.html">
</div>
<#include "../jsPage.html">
</body>
</html>
